package com.fourhats.model;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="item")
public class Item extends com.fourhats.model.Entity {

	@Column(name="name")
	private String name;
	
	@ManyToOne
    @JoinColumn(name="productId")
	private Product product;
	
	@ManyToOne
    @JoinColumn(name="brandId")
	private Brand brand;
	
	@OneToMany(mappedBy="item")
    private Set<Price> prices;
	
	@Column(name="description")
	private String description;
	
	@Column(name="enable")
	private boolean enable;
	
	@Column(name="imagePath")
	private String imagePath;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Brand getBrand() {
		return brand;
	}

	public void setBrand(Brand brand) {
		this.brand = brand;
	}
	
	public Set<Price> getPrices() {
		return prices;
	}

	public void setPrices(Set<Price> prices) {
		this.prices = prices;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getImagePath() {
		return imagePath;
	}

	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}

	public boolean isEnable() {
		return enable && this.product.isEnable() && this.brand.isEnable();
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}
}
